﻿using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using PMS.BusinessFacade;
using PMS.EntityManage;
using PMS.EntityQuery;
using PMS.Common;

public partial class Modules_System_ChangePassword : System.Web.UI.Page
{
    ISys_UserHandler userHandler = new Sys_UserManage();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        Sys_UserQuery query = userHandler.GetSys_UserQuery(Convert.ToInt32(Session["CurrentUserID"].ToString()));
        if (query != null)
        {
            if (query.Pwd != DesEncryption.EncryptPassword(txtOldPassword.Text.Trim(), "MD5"))
            {
                Jscript.Alert("旧密码不正确", this);
                return;
            }
        }

        query.Pwd = DesEncryption.EncryptPassword(txtNewPassword.Text.Trim(), "MD5");
        if (userHandler.UpdateSys_User(query))
        {
            Jscript.Alert("修改成功", this);
            Jscript.ReturnAndClose(this,"true");
        }
        else
        {
            Jscript.Alert("修改失败", this);

        }
    }
}
